-- kill_summon2
-- created by xinj
-- 击杀敌人概率召唤

return {
    apply = function(prop, baseValue)
        return prop[3];
    end,
    -- 触发
    trigger = function(who, prop, targetPos)

        if who.type ~= OBJECT_TYPE_USER then
            return;
        end

        -- 不满足概率
        if DungeonM.getRandSeed("kill_summon2") % 1000 >= prop[3] then
            return;
        end

        -- 如果此时怪物全清了
        if DungeonServiceM.isMonsterClear() then
            DungeonLogM.addLog("怪物全清了，不再召唤出召唤物。")
            return;
        end

        local element = tonumber(prop[2]);
        local class = DungeonM.queryElement(element, "class");
        local pos = SummonM.findSummonPos(targetPos);

        -- 如果没有位置了
        if pos <= 0 then
            return;
        end

        local para = { ["class"] = class, ["element"] = element };
        DungeonM.transformGrid(class, pos, GRID_STATE_OPEN, para);
    end,

    record = function(target, prop, path)
        return false;
    end
};
